package com.zyj.test.month1.day17;

/**
 * @author Yijia Zhang
 * @create 2024-06-06 23:58
 */
public class code2938_2 {
    //贪心算法
    public long minimumSteps(String s) {
        int len = s.length();
        if (len <= 1) {
            return 0;
        }
        char[] cs = s.toCharArray();
        int r = len - 1;
        long res = 0;
        int l = r;
        while (l >= 0) {
            char c = cs[l];
            if (c == '1') {
                res += (r - l);
                r--;
            }
            l--;
        }
        return res;
    }
}
